package com.windaka.elements.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * 配置 RestTemplate
 * @author song
 * @date 16:14 2021/11/17
**/
@Configuration
public class RestTemplateConfig {
	
	/**
	 * Bean RestTemplate
	 * @author song
	 * @date 16:14 2021/11/17
	**/
	@Bean
	public RestTemplate restTemplate() {
		SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
		// 设置连接超时，单位毫秒
		requestFactory.setConnectTimeout(3);
		// 设置读取超时
		requestFactory.setReadTimeout(5);
		RestTemplate restTemplate = new RestTemplate();
		restTemplate.setRequestFactory(requestFactory);
		return restTemplate;
	}

}
